Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SceneKit] Make SCNMatrix4 column-major in .NET. Fixes #4652. #13695

Merged
merged 4 commits into from
Jan 14, 2022

Conversation

rolfbjarne
Copy link
Member

  • Implement a column-major version of SCNMatrix4 in .NET to match native code.
  • This was done by copying the existing SCMatrix4 implementation, and modify it
    as required (doing it with conditional compilation in the same file turned out
    to be quite messy, so I opted for using different files for legacy Xamarin and
    .NET).
  • There was one major change: the matrix inversion algorithm is new (copied from
    .NET instead), because the legacy Xamarin version showed strange results with
    some test values.
  • Add setters for SCNMatrix4.Column[0-3] for legacy Xamarin to match the .NET API.
  • Add CreateFromColumns methods for legacy Xamarin to match the .NET API.
  • Add tests for all the new API.

Fixes #4652.

* Implement a column-major version of SCNMatrix4 in .NET to match native code.
* This was done by copying the existing SCMatrix4 implementation, and modify it
  as required (doing it with conditional compilation in the same file turned out
  to be quite messy, so I opted for using different files for legacy Xamarin and
  .NET).
* There was one major change: the matrix inversion algorithm is new (copied from
   .NET instead), because the legacy Xamarin version showed strange results with
  some test values.
* Add setters for SCNMatrix4.Column[0-3] for legacy Xamarin to match the .NET API.
* Add CreateFromColumns methods for legacy Xamarin to match the .NET API.
* Add tests for all the new API.

Fixes xamarin#4652.
@rolfbjarne rolfbjarne added not-notes-worthy Ignore for release notes run-dotnet-tests Run all the .NET tests breaking-change If an issue or a pull request represents a breaking change labels Jan 12, 2022
@vs-mobiletools-engineering-service2

This comment has been minimized.

pfloat d = -(2.0f * zFar * zNear) / (zFar - zNear);

result = new SCNMatrix4 (x, 0, 0, 0,
0, y, 0, 0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spacing looks maybe different than desired

SCNVector3 y = SCNVector3.Normalize (SCNVector3.Cross (z, x));

SCNMatrix4 rot = new SCNMatrix4 (new SCNVector4 (x.X, y.X, z.X, 0.0f),
new SCNVector4 (x.Y, y.Y, z.Y, 0.0f),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here as well

Copy link
Contributor

@tj-devel709 tj-devel709 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small possible spacing issues, but else good with me!

@rolfbjarne
Copy link
Member Author

CC @mattleibow in case this affects MAUI

@vs-mobiletools-engineering-service2
Copy link
Collaborator

❌ [PR Build] Tests failed on Build ❌

Tests failed on Build.

API diff

✅ API Diff from stable

View API diff
View dotnet API diff
View dotnet legacy API diff
View dotnet iOS-MacCatalayst API diff

API Current PR diff

ℹ️ API Diff (from PR only) (please review changes)

View API diff
View dotnet API diff
View dotnet legacy API diff
View dotnet iOS-MacCatalayst API diff

Generator diff

ℹ️ Generator Diff (please review changes)

GitHub pages

Results can be found in the following github pages (it might take some time to publish):

Test results

3 tests failed, 145 tests passed.

Failed tests

  • monotouch-test/Mac [dotnet]/Debug [dotnet]: Failed (Test run failed.
    Tests run: 2622 Passed: 2462 Inconclusive: 6 Failed: 1 Ignored: 159)
  • monotouch-test/Mac [dotnet]/Debug (static registrar) [dotnet]: Failed (Test run failed.
    Tests run: 2619 Passed: 2460 Inconclusive: 6 Failed: 1 Ignored: 158)
  • fsharp/Mac Catalyst [dotnet]/Debug [dotnet]: TimedOut ( (failed to parse the logs: The Writer is closed or in error state.))

Pipeline on Agent XAMBOT-1096.BigSur'
Merge f00f7b6 into 1109fce

@rolfbjarne
Copy link
Member Author

Test failures are unrelated:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change If an issue or a pull request represents a breaking change not-notes-worthy Ignore for release notes run-dotnet-tests Run all the .NET tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

XAMCORE_4_0: Our managed SCNMatrix4 is row-major, while the native SCNMatrix4 is column-major.
4 participants